package sms

import (
	"encoding/json"

	"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
)

// Send 发送短信验证码
func Send(code string) (response *dysmsapi.SendSmsResponse, err error) {
	client, err := dysmsapi.NewClientWithAccessKey("cn-hangzhou", "<accessKeyId>", "<accessSecret>")

	request := dysmsapi.CreateSendSmsRequest()
	request.Scheme = "https"

	request.PhoneNumbers = "13525256415"
	request.SignName = "xxxxxxx"
	request.TemplateCode = "xxxxxxx"
	params := map[string]string{
		"code": code,
	}
	TemplateParam, _ := json.Marshal(params)
	request.TemplateParam = string(TemplateParam)
	response, err = client.SendSms(request)
	return response, err
}
